const exportHeader = new Map()
    .set('id', '编号')
    .set('featureInfo', '特征信息')
    .set('description', '详细说明')

const app = new BasicTableVue({
    data() {
        return {
            api:sysFeatureApi,
            sysFeature:new SysFeatureVo(),
            updateVisible:false,
            categoryList:[],
            dtitle:'',
            timeArray:[],
            formLabelWidth: '70px',
            columns: [
                new TableColumn({width: 30, type: 'selection'}),
                TableColumn.generate({prop: 'id', title: '编号',}),
                TableColumn.generate({prop: 'featureInfo', title: '特征信息'}),
                TableColumn.generate({prop: 'description', title: '详细说明'}),
                new TableColumn({prop: 'operating', title: '操作', customComponent: true}),
                new TableColumn({prop: 'del', title: '删除', customComponent: true}),
            ],

        }
    },
    methods: {
        createForm() {
            return new SysFeatureVo();
        },
        async getPage(page, entity) {
            return await sysFeatureApi.page(page, entity)

        },

        addInfo(){
            this.dtitle='新增';
            this.updateVisible=true;
            this.sysFeature ={};
        },
        updateInfo(row){
            this.dtitle='修改';
            this.sysFeature = {...row}
            this.updateVisible=true;
        },

        async updateSysFeature(){
            var res=true;
            var msg='';
            if(typeof(this.sysFeature.id) != "undefined"){
                res = await this.api.update({
                    ...this.sysFeature,
                })
                msg= "更新";
            }else {
                this.sysFeature.createTime=new Date();
                res = await this.api.add({
                    ...this.sysFeature,
                })
                msg = "新增"
            }
            if (res.code !== 200 || res.data !== true) {
                msg+="失败";
                return
            }else{
                msg+="成功";
            }
            await rxPrompt.msg(msg);
            await this.searchPage();
        },

        async del(row) {
            var id=row.id;
            if (id!=null && id!='') {
                const res = await rxPrompt.confirm('你确认要删除该记录吗?？', ['确认', '取消'])
                if (res) {
                    const result = await this.api.deleteById(id);
                    // noinspection JSIgnoredPromiseFromCall
                    if(result){
                        rxPrompt.msg('删除成功')
                        await this.searchPage()
                    }
                }
            } else {
                await rxPrompt.msg('操作失败')
            }

        },

        async init() {

        },


    },
    computed: {
        fieldFormatter() {
            return fieldFormatter
        },
    },

})
